<?php
session_start();

$md5_hash = md5(rand(0,999)); 
$security_code = substr($md5_hash, 0, 5); 
$_SESSION["security_code"] = $security_code;
$width = 100; 
$height = 30; 
$image =ImageCreate($width,$height);
$font = 'font/gothic.TTF';
$text_color = ImageColorAllocate($image, 0, 0, 0); 
$background_color  = ImageColorAllocate($image,rand(30,255), rand(30,255), rand(30,230)); 
$line_color = $background_color;

ImageFill($image, 0, 0, $background_color); 
imagettftext($image,20,0,20,25,$text_color,$font,$security_code);
for( $i=0; $i<15; $i++ ) {

imageline($image, rand(0,$width), rand(0,$height),


rand(0,$width), rand(0,$height), $line_color);

}

header("Content-Type: image/jpeg"); 
ImageJpeg($image); 
ImageDestroy($image); 
exit();
?>